<template>
  <view v-if="shenheStatus == 0" class="r_box">
    <view class="top_text"
      >{{ $t('coupon.validity') }}{{ detail.sale_info.sale_time }} -
      {{ detail.sale_info.valid_time }}
    </view>
    <view class="cell_box">
      <view style="color: #888; font-size: 28rpx; margin-bottom: 20rpx">
        <text>{{ $t('writeOff.useCount') }}</text>
        <text style="float: right">{{ $t('writeOff.discount') }}</text>
      </view>
      <view style="font-size: 30rpx">
        <text>{{ detail.sale_info.use_num }}</text>
        <text style="float: right">{{ detail.sale_info.coupon_money }}</text>
      </view>
    </view>
    <view
      class="cell_box"
      v-for="(item, index) in detail.log_list"
      :key="index"
    >
      <view style="font-size: 28rpx; margin-bottom: 20rpx">{{
        item.use_time
      }}</view>
      <view style="font-size: 28rpx; color: #888888"
        >{{ $t('writeOff.shop') }}：{{ item.shop_name }}</view
      >
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components: { Shenhe },
  data() {
    return {
      detail: {},
    };
  },
  onLoad(opt) {
    uni.setNavigationBarTitle({
      title: this.$t('title.writeOffRecord'),
    });
    this.getDetailById(opt.id);
  },
  methods: {
    async getDetailById(id) {
      try {
        const res = await this.$allrequest.coupon.verifyLog({
          sale_id: id,
        });
        if (res.code == 0) {
          this.detail = res.data;
        } else {
          this.$utils.toast(res.msg);
        }
      } catch (e) {
        //TODO handle the exception
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.cell_box {
  background-color: #fff;
  padding: 30rpx 40rpx;
  margin-bottom: 20rpx;
}
.top_text {
  padding: 30rpx 40rpx;
  color: #888;
  font-size: 28rpx;
}
.r_box {
  background-color: rgb(246, 246, 246);
  min-height: 100vh;
}
</style>
